package net.fdukedom.epicurus.domain.entity;

import java.util.HashSet;
import java.util.Set;

public final class Group {
    /**
     * Group id.
     */
    private int id;

    /**
     * Group name.
     */
    private String name;

    /**
     * Related plugin.
     */
    private Plugin plugin;

    /**
     * Default constructor.
     * NB! Required by hibernate
     */
    public Group() {

    }

    /**
     * Creates instance out of name and plug-in
     * @param name group name
     * @param plugin parent plug-in
     */
    public Group(String name, Plugin plugin) {
        this.name = name;
        this.plugin = plugin;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the plugin
     */
    public Plugin getPlugin() {
        return plugin;
    }

    /**
     * @param plugin the plugin to set
     */
    public void setPlugin(Plugin plugin) {
        this.plugin = plugin;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        final Group group = (Group) o;

        if (name != null ? !name.equals(group.name) : group.name != null) return false;

        return true;
    }

    public int hashCode() {
        return (name != null ? name.hashCode() : 0);
    }
}
